package com.learn.shop.controller;

import com.learn.shop.constant.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@Controller
public class IndexController {

    /**
     * 首页
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {
        return "/index";
    }

    /**
     * 注销
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "logout", method = RequestMethod.GET)
    public R logout(HttpServletRequest request) {
        HttpSession session = request.getSession();
        int res = 200;
        session.removeAttribute("username");
        session.removeAttribute("password");
        return R.ok();
    }

  /*  @RequestMapping("/")
    public ModelAndView test(ModelAndView model){
        model.setViewName("login.html");
        return model;
    }*/
}
